home *** CD-ROM | disk | FTP | other *** search
/ Aminet 49 / Aminet 49 (2002)(GTI - Schatztruhe)[!][Jun 2002].iso / Aminet / util / boot / WBSP_Prefs.lha / WBStartup+Prefs / Source / CopyWindow.c < prev    next >
C/C++ Source or Header  |  2002-03-05  |  4KB  |  133 lines

  1. #include <exec/types.h>
  2. #include <libraries/mui.h>
  3. #include <proto/exec.h>
  4. #include <proto/intuition.h>
  5. #include <proto/muimaster.h>
  6.  
  7. #include "CopyWindow.h"
  8. #include "WBStartup+Prefs.h"
  9. #include "WBStartupPlusPrefs_Cat.h"
  10.  
  11. int CopyWindow(int flags)
  12. {
  13.   /* RETURNS the new flags */
  14.  
  15.   ULONG signals,returnid;
  16.   BOOL LOOP;
  17.   UBYTE *labels[3];
  18.   UBYTE *labels2[3];
  19.   ULONG active;
  20.  
  21.   int newflags=0;
  22.  
  23.   Object *cwindow,*cradio1,*cradio2,*cokobj,*ccancelobj;
  24.  
  25.   labels[0]=(UBYTE *)GetString(STREnabled);
  26.   labels[1]=(UBYTE *)GetString(STRDisabled);
  27.   labels[2]=NULL;
  28.  
  29.   labels2[0]=(UBYTE *)GetString(STRCopyFile);
  30.   labels2[1]=(UBYTE *)GetString(STRMoveFile);
  31.   labels2[2]=NULL;
  32.  
  33.   cwindow=MUI_NewObject("Window.mui",MUIA_Window_RefWindow,winobj,
  34.                        MUIA_Window_LeftEdge,MUIV_Window_LeftEdge_Centered,
  35.                      MUIA_Window_TopEdge,MUIV_Window_TopEdge_Centered,
  36.                      MUIA_Window_ID,3,
  37.                      MUIA_Window_Title,GetString(STRAddPrograms),
  38.                      MUIA_Window_RootObject,
  39.     MUI_NewObject("Group.mui",MUIA_Group_Child,
  40.         MUI_NewObject("Group.mui",MUIA_Background,MUII_GroupBack,
  41.                       MUIA_Frame,MUIV_Frame_Group,
  42.                       MUIA_FrameTitle,GetString(STRStatusOfPrograms),
  43.                       MUIA_Group_Horiz,TRUE,
  44.                       MUIA_Group_Child,
  45.             MUI_MakeObject(MUIO_HSpace,0),
  46.                       MUIA_Group_Child,
  47.             cradio1=MUI_NewObject("Radio.mui",MUIA_Radio_Entries,labels,
  48.                               MUIA_Radio_Active,(flags & WBSP_ENABLED) ? 0: 1,
  49.                               MUIA_CycleChain,TRUE,
  50.             TAG_DONE),
  51.                       MUIA_Group_Child,
  52.             MUI_MakeObject(MUIO_HSpace,0),
  53.         TAG_DONE),
  54.                   MUIA_Group_Child,
  55.         MUI_NewObject("Group.mui",MUIA_Background,MUII_GroupBack,
  56.                       MUIA_Frame,MUIV_Frame_Group,
  57.                       MUIA_FrameTitle,GetString(STROperation),
  58.                       MUIA_Group_Horiz,TRUE,
  59.                       MUIA_Group_Child,
  60.             MUI_MakeObject(MUIO_HSpace,0),
  61.                       MUIA_Group_Child,
  62.             cradio2=MUI_NewObject("Radio.mui",MUIA_Radio_Entries,labels2,
  63.                               MUIA_Radio_Active,(flags & WBSP_MOVE) ? 1 : 0,
  64.                               MUIA_CycleChain,TRUE,
  65.             TAG_DONE),
  66.                       MUIA_Group_Child,
  67.             MUI_MakeObject(MUIO_HSpace,0),
  68.         TAG_DONE),
  69.                   MUIA_Group_Child,
  70.         MUI_NewObject("Group.mui",MUIA_Group_Horiz,TRUE,
  71.                       MUIA_Group_Child,
  72.             cokobj=MUI_NewObject("Text.mui",MUIA_CycleChain,TRUE,
  73.                             MUIA_Frame,MUIV_Frame_Button,
  74.                             MUIA_Background,MUII_ButtonBack,
  75.                                 MUIA_InputMode,MUIV_InputMode_RelVerify,
  76.                                 MUIA_Text_Contents,GetString(STROk),
  77.                                 MUIA_Text_PreParse,"\33c",
  78.             TAG_DONE),
  79.                       MUIA_Group_Child,
  80.             ccancelobj=MUI_NewObject("Text.mui",MUIA_CycleChain,TRUE,
  81.                                 MUIA_Frame,MUIV_Frame_Button,
  82.                                 MUIA_Background,MUII_ButtonBack,
  83.                                 MUIA_InputMode,MUIV_InputMode_RelVerify,
  84.                                 MUIA_Text_Contents,GetString(STRCancel),
  85.                                 MUIA_Text_PreParse,"\33c",
  86.             TAG_DONE),
  87.         TAG_DONE),
  88.     TAG_DONE),
  89.   TAG_DONE);
  90.  
  91.   if (!cwindow)
  92.       return(WBSP_CANCEL);
  93.   DoMethod(appobj,OM_ADDMEMBER,cwindow);
  94.   DoMethod(cwindow,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,appobj,2,MUIM_Application_ReturnID,1);
  95.   DoMethod(ccancelobj,MUIM_Notify,MUIA_Pressed,FALSE,appobj,2,MUIM_Application_ReturnID,1);
  96.   DoMethod(cokobj,MUIM_Notify,MUIA_Pressed,FALSE,appobj,2,MUIM_Application_ReturnID,2);
  97.   SetAttrs(cwindow,MUIA_Window_Open,TRUE,TAG_DONE);
  98.  
  99.   signals=0;
  100.   LOOP=TRUE;
  101.   while (LOOP)
  102.   {
  103.       if (signals)
  104.           signals=Wait(signals);
  105.       returnid=DoMethod(appobj,MUIM_Application_NewInput,&signals);
  106.       switch (returnid)
  107.       {
  108.           case 1:
  109.               newflags |= WBSP_CANCEL;
  110.               LOOP=FALSE;
  111.           break;
  112.           case 2:
  113.               LOOP=FALSE;
  114.           break;
  115.           case MUIV_Application_ReturnID_Quit:
  116.               newflags |= WBSP_CANCEL;
  117.             DoMethod(appobj,MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit);
  118.             LOOP=FALSE;
  119.           break;
  120.       }
  121.   }
  122.   GetAttr(MUIA_Radio_Active,cradio1, &active);
  123.   if (!active)
  124.     newflags |= WBSP_ENABLED;
  125.   GetAttr(MUIA_Radio_Active,cradio2, &active);
  126.   if (active)
  127.     newflags |= WBSP_MOVE;
  128.   SetAttrs(cwindow,MUIA_Window_Open,FALSE,TAG_DONE);
  129.   DoMethod(appobj,OM_REMMEMBER,cwindow);
  130.   MUI_DisposeObject(cwindow);
  131.   return(newflags);
  132. }
  133.